// miniprogram/pages/leave_detail/leave_detail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],    //具体的请假信息
    stu_name: '',  //学生名字
    stu_id: '',   //学号
    stu_class: '',  //申请人班级
    stu_garde: '',  //申请人年级
    stu_days: 0,  //请假天数
    stu_destination: '',  //目的地
    stu_Travel_mode: '', //出行方式
    teacher_name: '',  //教师名字
    teacher_id: '', //教职工号
    other: '',   //请假原因
    stu_out: '',  //出行日期
    stu_come: '', //回来日期
    createdate: '',  //创建请假条的日期
    setdate: '',   //修改假条日期
    passdate: '',  //通过日期
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({   //获取上个页面传过来的数据
      list: JSON.parse(options.list)
    })
    var date_stu_come = new Date(this.data.list.stu_come).getTime();
    var date_createdate = new Date(this.data.list.createdate).getTime();
    var year_stu_come = new Date(date_stu_come).getFullYear();      //年
    var month_stu_come = new Date(date_stu_come).getMonth()+1;      //月
    var Date_stu_come = new Date(date_stu_come).getDate();          //日
    var hours_stu_come = new Date(date_stu_come).getHours();        //时
    var minutes_stu_come = new Date(date_stu_come).getMinutes();    //分
    var seconds_stu_come = new Date(date_stu_come).getSeconds();    //秒
    var year_createdate = new Date(date_createdate).getFullYear();      //年
    var month_createdate = new Date(date_createdate).getMonth()+1;      //月
    var Date_createdate = new Date(date_createdate).getDate();          //日
    var hours_createdate = new Date(date_createdate).getHours();        //时
    var minutes_createdate = new Date(date_createdate).getMinutes();    //分
    var seconds_createdate = new Date(date_createdate).getSeconds();    //秒
    if(month_stu_come < 10){
      month_stu_come = "0" + month_stu_come
    }
    if(Date_stu_come < 10){
      Date_stu_come = "0" + Date_stu_come
    }
    if(hours_stu_come < 10){
      hours_stu_come = "0" + hours_stu_come
    }
    if(minutes_stu_come < 10){
      minutes_stu_come = "0" + minutes_stu_come
    }
    if(seconds_stu_come < 10){
      seconds_stu_come = "0" + seconds_stu_come
    }
    if(month_createdate < 10){
      month_createdate = "0" + month_createdate
    }
    if(Date_createdate < 10){
      Date_createdate = "0" + Date_createdate
    }
    if(hours_createdate < 10){
      hours_createdate = "0" + hours_createdate
    }
    if(minutes_createdate < 10){
      minutes_createdate = "0" + minutes_createdate
    }
    if(seconds_createdate < 10){
      seconds_createdate = "0" + seconds_createdate
    }
    this.setData({
      stu_come: year_stu_come+'-'+month_stu_come+'-'+Date_stu_come+' '+hours_stu_come+':'+minutes_stu_come+':'+seconds_stu_come,
      createdate: year_createdate+'-'+month_createdate+'-'+Date_createdate+' '+hours_createdate+':'+minutes_createdate+':'+seconds_createdate,
    })
    this.chance();
  },

  chance(){
    if(this.data.list.setdate){     //判断修改假条日期是否为空后再转换时间
      var date_setdate = new Date(this.data.list.setdate).getTime();
      var year_setdate = new Date(date_setdate).getFullYear();      //年
      var month_setdate = new Date(date_setdate).getMonth()+1;      //月
      var Date_setdate = new Date(date_setdate).getDate();          //日
      var hours_setdate = new Date(date_setdate).getHours();        //时
      var minutes_setdate = new Date(date_setdate).getMinutes();    //分
      var seconds_setdate = new Date(date_setdate).getSeconds();    //秒
      if(month_setdate < 10){
        month_setdate = "0" + month_setdate
      }
      if(Date_setdate < 10){
        Date_setdate = "0" + Date_setdate
      }
      if(hours_setdate < 10){
        hours_setdate = "0" + hours_setdate
      }
      if(minutes_setdate < 10){
        minutes_setdate = "0" + minutes_setdate
      }
      if(seconds_setdate < 10){
        seconds_setdate = "0" + seconds_setdate
      }
      this.setData({
        setdate: year_setdate+'-'+month_setdate+'-'+Date_setdate+' '+hours_setdate+':'+minutes_setdate+':'+seconds_setdate
      })
    }
    if(this.data.list.passdate){     //判断通过日期是否为空后再转换时间
      var date_passdate = new Date(this.data.list.passdate).getTime();
      var year_passdate = new Date(date_passdate).getFullYear();      //年
      var month_passdate = new Date(date_passdate).getMonth()+1;      //月
      var Date_passdate = new Date(date_passdate).getDate();          //日
      var hours_passdate = new Date(date_passdate).getHours();        //时
      var minutes_passdate = new Date(date_passdate).getMinutes();    //分
      var seconds_passdate = new Date(date_passdate).getSeconds();    //秒
      if(month_passdate < 10){
        month_passdate = "0" + month_passdate
      }
      if(Date_passdate < 10){
        Date_passdate = "0" + Date_passdate
      }
      if(hours_passdate < 10){
        hours_passdate = "0" + hours_passdate
      }
      if(minutes_passdate < 10){
        minutes_passdate = "0" + minutes_passdate
      }
      if(seconds_passdate < 10){
        seconds_passdate = "0" + seconds_passdate
      }
      this.setData({
        passdate: year_passdate+'-'+month_passdate+'-'+Date_passdate+' '+hours_passdate+':'+minutes_passdate+':'+seconds_passdate
      })
    }
    this.setData({
      stu_name: this.data.list.stu_name,  
      stu_id: this.data.list.stu_id,   
      stu_class: this.data.list.stu_class,  
      stu_garde: this.data.list.stu_garde,  
      stu_days: this.data.list.stu_days,  
      stu_out: this.data.list.stu_out,
      stu_destination: this.data.list.stu_destination,  
      stu_Travel_mode: this.data.list.stu_Travel_mode, 
      teacher_name: this.data.list.teacher_name,  
      teacher_id: this.data.list.teacher_id, 
      other: this.data.list.other
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})